<template>
  <textarea id="editor" placeholder="kujomiva" />
</template>

<script>
// Simditor
import Simditor from 'simditor'
import 'simditor/styles/simditor.css'
// jquery
import $ from 'jquery'
export default {
  data() {
    return {
      editer: null,
      editerData: 'dsadsa'
    }
  },
  watch: {
    editerData(val) {
      console.log(val)
    }
  },
  mounted() {
    //   创建富文本编辑器
    this.createEditer()
  },
  methods: {
    //   创建富文本编辑器
    createEditer() {
      this.editer = new Simditor({
        textarea: $('#editor'),
        defaultImage: 'http://placehold.it/200x200',
        pasteImage: true,
        upload: {
          // url: process.env.VUE_APP_BASE_API + '/OSS_stream',
          url: 'http://127.0.0.1:7001/OSS_stream',
          params: null,
          fileKey: 'upload_file',
          connectionCount: 3,
          leaveConfirm: 'Uploading is in progress, are you sure to leave this page?'
        }
      })
      this.editer.on('valuechanged', (e, src) => {
        const data = this.editer.getValue()
        this.$emit('change', data)
      })
    }
  }
}
</script>
